/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Akanksha;

/**
 *
 * @author Akanksha Chauhan
 */
public class Battery {
    
    private static double batteryLevel;
    
    public static double getBatteryLevel()
    {
        return batteryLevel;
    }
    public static void startUsingBattery()
    {      
        
        if(checkBatteryLevelEmpty())
        {
            Alarm alarm = new Alarm();
            alarm.setAlarm("Battery Empty");  
        }
        else
        { 
            // test is ahead of current time by 1 minute
            int test = Clock.GetCurrentMinute() +1;
            // iterates 1 time / minute
            for(int counter = 1 ; counter <= 50; counter++)
            {
                // waits for 1 minute and then gives insulin to user
                while(Clock.GetCurrentMinute() != test)
                {
                    //wait    
                }
                     batteryLevel = batteryLevel - 1;
                     System.out.println(batteryLevel);
                     test = test +1;
                if(batteryLevel == 5)
                {
                    Alarm alarm = new Alarm();
                    alarm.setAlarm("Battery Critically Low");
                }
                if(batteryLevel == 1)
                {
                   Alarm alarm = new Alarm();
                   alarm.setAlarm("Battery Empty"); 
                   break;
                }
            }
            
        }
    }
        
            public static void setBatteryLevel(double batteryLeft)
            {
                batteryLevel = batteryLeft;
                System.out.println(batteryLevel);
            }
            // TO Do -- should shut down system when battery dies
        
    

        public static boolean checkBatteryLevelEmpty()
        {
            if (batteryLevel == 0)
                return true;
            else
                return false;
        }
        
         
         
    
}